package com.wf.springboot.server.controller;

import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.wf.springboot.common.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author wf
 * @since 2024-07-21
 */
@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @PostMapping("/login")
    public Result login() {
        StpUtil.login(1);
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        return Result.success(tokenInfo);
    }

    @PostMapping("/logout")
    public Result logout(){
        StpUtil.logout();
        return Result.success();
    }

    @GetMapping("/getLoginEquipment")
    public Result getLoginEquipment(){
        String loginDevice = StpUtil.getLoginDevice();
        return Result.success(loginDevice);
    }
}
